<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use App\Services\AuthService;
use Illuminate\Http\Request;

class UsersAuthController extends Controller
{
    protected $service;

    function __construct(AuthService $authService)
    {
        $this->service = $authService;
        $this->service->setGuard('user');
    }

    public function store(Request $request)
    {
        $this->validate($request, [
            'user_name' => 'required|string',
            'password' => 'required|string'
        ]);
        return $this->service->login($request->user_name, $request->password);
    }

    public function update()
    {
        return $this->service->refreshToken();
    }

    public function destroy()
    {
        return $this->service->deleteToken();
    }
}
